/*
package org.example.spring.self.demo.service;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.jdbc.core.JdbcTemplate;
import org.springframework.stereotype.Component;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Component
public class OrderService {

	@Autowired
	private JdbcTemplate jdbcTemplate;

	@Autowired
	private OrderService orderService;

	@Transactional
	public void test() {
		// 开启事务
		// 1. 事务管理器新建一个数据库连结 conn ThreadLocal<Map<DataSource, conn>> (使用ThreadLocal拿到数据库连接)
		// 2. conn.autocommit = false
		// target.test(); // 普通对象.test() jdbcTemplate DataSource对象 conn
		// conn.commit() conn.rollback()

		jdbcTemplate.execute("insert into a values(1, '1')");

		// test2() 会抛异常
		orderService.test2();
	}

	// NEVER 有事物存在的情况会抛出异常
	@Transactional(propagation = Propagation.NEVER)
	public void test2() {
		jdbcTemplate.execute("insert into a values(2, '2')");
	}
}
*/
